.class public Lcom/esfile/screen/recorder/media/util/i;
.super Ljava/lang/Object;
.source "DuFileDecorater.java"


# direct methods
.method public static a(Ljava/io/File;)Ljava/lang/String;
    .locals 5
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    if-eqz p0, :cond_2

    .line 16
    invoke-virtual {p0}, Ljava/io/File;->exists()Z

    move-result v0

    if-eqz v0, :cond_2

    .line 17
    invoke-virtual {p0}, Ljava/io/File;->canRead()Z

    move-result v0

    if-eqz v0, :cond_1

    .line 18
    new-instance v0, Ljava/io/RandomAccessFile;

    const-string v1, "r"

    invoke-direct {v0, p0, v1}, Ljava/io/RandomAccessFile;-><init>(Ljava/io/File;Ljava/lang/String;)V

    .line 19
    invoke-virtual {p0}, Ljava/io/File;->length()J

    move-result-wide v1

    const-wide/16 v3, 0x4

    sub-long v3, v1, v3

    .line 20
    invoke-virtual {v0, v3, v4}, Ljava/io/RandomAccessFile;->seek(J)V

    .line 21
    invoke-virtual {v0}, Ljava/io/RandomAccessFile;->readInt()I

    move-result p0

    const v3, 0x37f00643

    if-eq p0, v3, :cond_0

    const-string p0, "DuFileDecorater"

    const-string v0, "This file is either not Du File or have not description info"

    .line 22
    invoke-static {p0, v0}, Lcom/esfile/screen/recorder/media/util/k;->d(Ljava/lang/String;Ljava/lang/String;)V

    const/4 p0, 0x0

    return-object p0

    :cond_0
    const-wide/16 v3, 0x8

    sub-long/2addr v1, v3

    .line 23
    invoke-virtual {v0, v1, v2}, Ljava/io/RandomAccessFile;->seek(J)V

    .line 24
    invoke-virtual {v0}, Ljava/io/RandomAccessFile;->readInt()I

    move-result p0

    int-to-long v3, p0

    sub-long/2addr v1, v3

    .line 25
    invoke-virtual {v0, v1, v2}, Ljava/io/RandomAccessFile;->seek(J)V

    .line 26
    new-array p0, p0, [B

    .line 27
    invoke-virtual {v0, p0}, Ljava/io/RandomAccessFile;->read([B)I

    .line 28
    invoke-static {v0}, Lcom/esfile/screen/recorder/media/util/i;->a(Ljava/io/Closeable;)V

    .line 29
    new-instance v0, Ljava/lang/String;

    const-string v1, "UTF-8"

    invoke-direct {v0, p0, v1}, Ljava/lang/String;-><init>([BLjava/lang/String;)V

    return-object v0

    .line 30
    :cond_1
    new-instance p0, Ljava/lang/IllegalStateException;

    const-string v0, "Permission denied when reading file"

    invoke-direct {p0, v0}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V

    throw p0

    .line 31
    :cond_2
    new-instance p0, Ljava/lang/IllegalArgumentException;

    const-string v0, "file is not exist"

    invoke-direct {p0, v0}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw p0
.end method

.method private static a(Ljava/io/Closeable;)V
    .locals 0

    if-eqz p0, :cond_0

    .line 45
    :try_start_0
    invoke-interface {p0}, Ljava/io/Closeable;->close()V
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    goto :goto_0

    :catchall_0
    move-exception p0

    .line 46
    invoke-virtual {p0}, Ljava/lang/Throwable;->printStackTrace()V

    :cond_0
    :goto_0
    return-void
.end method

.method public static a(Ljava/io/File;Ljava/io/RandomAccessFile;Z)V
    .locals 4
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    if-eqz p0, :cond_3

    .line 32
    invoke-virtual {p0}, Ljava/io/File;->exists()Z

    move-result v0

    if-eqz v0, :cond_3

    .line 33
    invoke-virtual {p0}, Ljava/io/File;->canRead()Z

    move-result v0

    if-eqz v0, :cond_2

    .line 34
    invoke-virtual {p0}, Ljava/io/File;->length()J

    move-result-wide v0

    const-wide/16 v2, 0x4

    sub-long v2, v0, v2

    .line 35
    invoke-virtual {p1, v2, v3}, Ljava/io/RandomAccessFile;->seek(J)V

    .line 36
    invoke-virtual {p1}, Ljava/io/RandomAccessFile;->readInt()I

    move-result p0

    const v2, 0x37f00643

    if-eq p0, v2, :cond_0

    const-string p0, "DuFileDecorater"

    const-string p1, "Don\'t detect Du file description data, nothing need to clear."

    .line 37
    invoke-static {p0, p1}, Lcom/esfile/screen/recorder/media/util/k;->d(Ljava/lang/String;Ljava/lang/String;)V

    return-void

    :cond_0
    const-wide/16 v2, 0x8

    sub-long/2addr v0, v2

    .line 38
    invoke-virtual {p1, v0, v1}, Ljava/io/RandomAccessFile;->seek(J)V

    .line 39
    invoke-virtual {p1}, Ljava/io/RandomAccessFile;->readInt()I

    move-result p0

    int-to-long v2, p0

    sub-long/2addr v0, v2

    .line 40
    invoke-virtual {p1, v0, v1}, Ljava/io/RandomAccessFile;->seek(J)V

    const/4 p0, 0x0

    .line 41
    invoke-virtual {p1, p0}, Ljava/io/RandomAccessFile;->writeByte(I)V

    if-eqz p2, :cond_1

    .line 42
    invoke-static {p1}, Lcom/esfile/screen/recorder/media/util/i;->a(Ljava/io/Closeable;)V

    :cond_1
    return-void

    .line 43
    :cond_2
    new-instance p0, Ljava/lang/IllegalStateException;

    const-string p1, "Permission denied when writing file"

    invoke-direct {p0, p1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V

    throw p0

    .line 44
    :cond_3
    new-instance p0, Ljava/lang/IllegalArgumentException;

    const-string p1, "file is not exist"

    invoke-direct {p0, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw p0
.end method

.method public static a(Ljava/io/File;Ljava/lang/String;Z)V
    .locals 3
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/Exception;
        }
    .end annotation

    if-eqz p0, :cond_3

    .line 1
    invoke-virtual {p0}, Ljava/io/File;->exists()Z

    move-result v0

    if-eqz v0, :cond_3

    .line 2
    invoke-virtual {p0}, Ljava/io/File;->canRead()Z

    move-result v0

    if-eqz v0, :cond_2

    invoke-virtual {p0}, Ljava/io/File;->canWrite()Z

    move-result v0

    if-eqz v0, :cond_2

    .line 3
    invoke-static {p1}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v0

    if-eqz v0, :cond_0

    const-string p0, "DuFileDecorater"

    const-string p1, "\'Description\' is empty, have not append any thing to file"

    .line 4
    invoke-static {p0, p1}, Lcom/esfile/screen/recorder/media/util/k;->d(Ljava/lang/String;Ljava/lang/String;)V

    return-void

    :cond_0
    const/4 v0, 0x0

    :try_start_0
    const-string v1, "UTF-8"

    .line 5
    invoke-virtual {p1, v1}, Ljava/lang/String;->getBytes(Ljava/lang/String;)[B

    move-result-object v0
    :try_end_0
    .catch Ljava/io/UnsupportedEncodingException; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    :catch_0
    nop

    .line 6
    :goto_0
    new-instance p1, Ljava/io/RandomAccessFile;

    const-string v1, "rw"

    invoke-direct {p1, p0, v1}, Ljava/io/RandomAccessFile;-><init>(Ljava/io/File;Ljava/lang/String;)V

    if-eqz p2, :cond_1

    const/4 p2, 0x0

    .line 7
    invoke-static {p0, p1, p2}, Lcom/esfile/screen/recorder/media/util/i;->a(Ljava/io/File;Ljava/io/RandomAccessFile;Z)V

    .line 8
    :cond_1
    array-length p2, v0

    .line 9
    invoke-virtual {p0}, Ljava/io/File;->length()J

    move-result-wide v1

    invoke-virtual {p1, v1, v2}, Ljava/io/RandomAccessFile;->seek(J)V

    .line 10
    invoke-virtual {p1, v0}, Ljava/io/RandomAccessFile;->write([B)V

    .line 11
    invoke-virtual {p1, p2}, Ljava/io/RandomAccessFile;->writeInt(I)V

    const p0, 0x37f00643

    .line 12
    invoke-virtual {p1, p0}, Ljava/io/RandomAccessFile;->writeInt(I)V

    .line 13
    invoke-static {p1}, Lcom/esfile/screen/recorder/media/util/i;->a(Ljava/io/Closeable;)V

    return-void

    .line 14
    :cond_2
    new-instance p0, Ljava/lang/IllegalStateException;

    const-string p1, "Permission denied when writing file"

    invoke-direct {p0, p1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V

    throw p0

    .line 15
    :cond_3
    new-instance p0, Ljava/lang/IllegalArgumentException;

    const-string p1, "File is not exist"

    invoke-direct {p0, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V

    throw p0
.end method
